$(document).ready(function(){
	$('#dateChoose_span a').click(function(e){
      	inputForDate(e,$(this),$('#dateRangePicker'));
        $("#dateTab").val($(this).attr("value"));
        $(this).addClass('dateChange').siblings('.dateChange').removeClass('dateChange');
    });
	
	if($('#calendar_span').html()){
		$('#dateRangePicker').dateRangePicker();
		if($('#dateRangePicker').val() == ""){
			$('#dateRangePicker').val(getlastDate(1)+" to "+getlastDate(1));
			$("#date #yesterday").addClass('dateChange');
			$("#dateTab").val("yesterday");
		}
	}
	
	$('#dateChoose_span a').each(function(){
		var value = $(this).attr("value");
		if($("#dateTab").val() == value){
			$(this).addClass('dateChange');
		}
	});
	//点击日期控件的按钮时，去掉前面时间标签的样式
	$(".apply-btn").click(function(){
		if(!$(this).hasClass("disabled")){
			$("#dateTab").val("");
			$('#dateChoose_span a').removeClass('dateChange');
			$('#dateRangePicker').val($(".start-day").text() +" to "+$(".end-day").text());
		}
	});
	
	// 分页中超链接跳转
	$('#pagecontent .pagination ul li a[href]').click(function(){
		var _page = $(this).attr('href').substr(1);
		var _form = $('#myform');
		_form.find('input:hidden[name="page"]').val(_page);
		_form.submit();
		return false;
	});
	
	$('ul#dimension_son_ul li').live("click",function(){
		$('#myform').submit();
	});
		
});

//导出execl
function exportExcel(tab,url){
	var checkboxs = $("#date-checkbox input[name='item']:checked");
	var checkboxStr = "";
	checkboxs.each(function(i){
		checkboxStr += $(this).val()+",";
	});
	if(checkboxStr!=""){
		checkboxStr = checkboxStr.substring(0,checkboxStr.length-1);
	}
    var params = "?"+tab+"=1&dateRangePicker="+$("#dateRangePicker").val()+"&selectedadvertiserId="+$("#advertiserId").val()+"&selectedorderId="+$("#orderId").val()+"&selecteddimensionId="+$("#dimensionId").val()+"&checkItems="+checkboxStr; 
	params += "&selectedadvertiserName="+$("#advertiserName").val()+"&selectedorderName="+$("#orderName").val();
	if (tab == 'banner') {
		params += "&selectedadGroupId="+$("#adGroupId").val()+"&selectedadGroupName="+$("#adGroupName").val();
	}
	$("#exportExcel").attr("href",url+params);
}
//曝光
function hideImpression(){
	$(".hidden-impression").toggle();
}
//点击
function hideClick(){	
	$(".hidden-click").toggle();
}
//到达
function hideVisit(){
	$(".hidden-visit").toggle();
}
//转化
function hideConversion(){
	$(".hidden-conversion").toggle();
}
//花费
function hideConsume(){	
	$(".hidden-consume").toggle();
}